from pydantic import BaseModel
from typing import List, Optional, Dict, Any

class Character(BaseModel):
    id: int
    name: str
    description: str
    image_url: str
    skills: List[str]
    system_prompt: str
    
    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'description': self.description,
            'image_url': self.image_url,
            'skills': self.skills
        }

class ChatMessage(BaseModel):
    role: str  # 'user' or 'assistant'
    content: str

class AIConfig(BaseModel):
    provider: str = 'mock'  # 'openai', 'free-ai', 'mock'
    openai_api_key: Optional[str] = None
    use_mock_fallback: bool = True

class ChatRequest(BaseModel):
    character_id: int
    message: str
    skill: Optional[str] = None
    history: List[ChatMessage] = []
    ai_config: Optional[AIConfig] = None